#===-- Patchsplit.py - Simple style checking for llvm       *- Python -*-
#
#                     The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
#===----------------------------------------------------------------------

from optparse import OptionParser
import glob
import os
import re
import fnmatch

parser = OptionParser("usage: %prog arg1 arg2 ... argn [options]");
(options, args) = parser.parse_args()

def doOnePatchFile(fname, topLevel):
  global state
  print fname;
  f = open(fname, 'r')
  lineNum = 0;
  line = f.readline();
  while line != "":
    # print line,
    if (len(line) > 3) and (line[0:3] == '---') :
      print "old file: ", line[3:],
      line = f.readline()
      if (len(line) > 3) and (line[0:3] == '+++') :
        print "new file: ", line[3:],
        line = f.readline()
        if (len(line) > 2 and line[0:2]=='@@'):
          print "chunk ", line[2:]
    line = f.readline() 
for x in args:
  g = glob.glob(x)
  for y in g:
    doOnePatchFile(y, True)

